<template>
    <div>
      <el-card class="box-card" @click="handleClick(1)">
        <template #header>
          <div class="card-header">
            <div @click.stop="handleClick(3)" v-if="choices">
              <el-checkbox style="width: 100%;" @change="change"  v-model="checked2">选择</el-checkbox>
            </div>
            
            <div v-if="!choices">
              <span class="text_2">{{ dataobjs.school_name }}</span>
            </div>
            <div v-if="!choices" @click.stop="handleClick(2)">
              <el-dropdown @command="handleCommand" trigger="click" v-if="is_operation" >
              <span class="el-dropdown-link">
                操作<el-icon class="el-icon--right"><arrow-down /></el-icon>
              </span>
              <template #dropdown>
                <el-dropdown-menu v-if="authority([3])||user.is_qstatus==2">
                    <el-dropdown-item command="a" @click="handleEditdk()" >转交代课</el-dropdown-item>
                    <el-dropdown-item command="a" @click="handleEditduke()" >转交督课</el-dropdown-item>
                  
                  
                  <el-dropdown-item command="a" @click="handleEdit('edit')" >编辑</el-dropdown-item>
                  <el-dropdown-item command="b" @click="handleEdit('delete')">删除</el-dropdown-item>
                </el-dropdown-menu>
                <el-dropdown-menu v-if="authority([5])&&qstatus==false">
                    <el-dropdown-item command="a" @click="handleEditdkxx()" >督课信息填写</el-dropdown-item> 
                </el-dropdown-menu>
                <el-dropdown-menu v-if="authority([4])">
                    <el-dropdown-item command="a" @click="handleEditdkxx()" >在地督课</el-dropdown-item> 
                </el-dropdown-menu>
              </template>
            </el-dropdown>
            </div>
            
          </div>
        </template>
        <div>
          <div class="text_item">
            <span class="text_1"
              >区域：{{ dataobjs.province }}{{ dataobjs.municipality }}{{ dataobjs.region }}(区/县)</span
            >
          </div>
          <div class="text_item">
            <span class="text_1">学校：{{ dataobjs.school_name }}</span>
          </div>
          <div class="text_item">
            <span class="text_1"
              >年级：{{ dataobjs.grade }}</span
            >
          </div>
          <div class="text_item">
            <span class="text_1"
              >班级：{{ dataobjs.calss }}</span
            >
          </div>
          <div class="text_item">
            <span class="text_1"
              >科目：{{ dataobjs.subject }}</span
            >
          </div>
          <div class="text_item">
            <span class="text_1"
              >上课时间：{{ dataobjs.calss_time }} {{ dataobjs.calss_time_last }}-{{ dataobjs.calss_time_slot }}</span
            >
          </div> 
          <div class="text_item">
            <span class="text_1"
              >是否首课：{{dataobjs.is_image==1?'是':'否'}}</span
            >
          </div> 
        </div>
  
        <div class="clearfix">
          <!-- <el-link type="info">{{ formatDateTime(item.updatetime) }}</el-link> -->
  
          <!-- <div>
              <el-link
                type="primary"
                style="margin-right: 10px"
                @click="handleEdit(item, 'edit')"
                >编辑</el-link
              >
              <el-link type="danger" @click="handleEdit(item, 'delete')"
                >删除</el-link
              >
            </div> -->
        </div>
        <!-- <template #footer  >
          <div class="card-footer">
            {{ dataobjs.createtime }}
          </div>
          </template> -->
      </el-card>
    </div>
  </template>
  
  <script>
  import { setStorage, getStorage } from "@/utils/util";
  import { useRouter, useRoute } from "vue-router";
  
  export default {
    props: {
      qstatus:{
        typeof: Boolean,
          default: false
      },
      user: {
        typeof: Object,
        default: {},
      },
      // 是否开启多选
      choices: { 
        typeof: Boolean,
          default: false
      },
      dataobjs: {
        typeof: Object,
        default: {},
      },
      is_operation:{
          typeof: Boolean,
          default: false
      }
    },
    data() {
      return {
        
        checked2:false,//当前选择
        userInfo:''
      };
    },
    created() {
      this.userInfo = Number(JSON.parse(getStorage("groupId"))); //权限
   
    },
    methods: {
      authority(groupArr = [0]) {
        // 权限筛选
        let userInfo = this.userInfo;
        // 当前权限和传来的权限组进行对比
        if (groupArr.some((item) => Number(item) === userInfo)) return true;
        return false;
      },
      change(e){
        // 选择的值发生变化
        //console.log(e,'------1')
        this.$emit('inspect',e,this.dataobjs.id)
        // this.$emit('change',this.checked2)
      },
      handleClick(i){
        if(this.choices) return
        if(i==1){
          this.$router.push({path:`/h5_online_details`,query:{id:this.dataobjs.id}})
        }
        if(i==2){
          //console.log('点击操作',i)
        }
        if(i==3){
          // this.checked2 = !this.checked2
          //console.log('点击选择')
        }
      },
      handleEdit(i){
        // 删除
        this.$emit('handleEdit',this.dataobjs,i)
      },
      openOkAll(i,id){
        // 驳回和通过
        this.$emit('openOkAll',i,id)
      },
      openOk(obj){
        // 确认排课
        this.$emit('openOk',obj)
  
      },
      handleEditdk(obj){
        this.$emit('handleEditdk',this.dataobjs)

      },
      handleEditduke(){
        // 转交督课
        this.$emit('handleEditduke',this.dataobjs)
      },
      handleEditdkxx(){
        this.$emit('handleEditdkxx',this.dataobjs)
      }
    }
  };
  </script>
  
  <style>
  .card-header {
    display: flex;
    justify-content: space-between; 
  }
  .text_item {
    line-height: 24px !important;
    font-size: 14px !important;
  }
  .clearfix {
    display: flex;
    justify-content: space-between;
    width: 100%;
    align-items: center;
    padding-top: 10px;
    font-size: 14px;
  }
  .card-footer{
    font-size: 13px;
  }
  .text_2{
    font-size: 14px;
  }
  </style>
  